package com.pphh.demo.service;

import com.pphh.demo.dao.UserInfoDAO;
import com.pphh.demo.model.UserInfoDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class UserAService {

    @Autowired
    UserBService userBService;

    @Autowired
    UserInfoDAO userInfoDAO;

    @Transactional(value = "txManager")
    public UserInfoDTO insertUser(UserInfoDTO user) {
        user.setUserName("service-a");
        userInfoDAO.insert(user);

        try {
            userBService.insertUser(user);
        } catch (Throwable e) {
            System.out.println(e.toString());
        }
        return user;
    }
}
